<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登陆页面</title>
    <link  href="../static/css/style.css" rel="stylesheet" media="screen">
    <link  href="../static/css/reset.css" rel="stylesheet" type="text/css"/>
    <link href="../static/layui/css/layui.css" rel="stylesheet" type="text/css" />

</head>
<body>
<div id="particles-js">
    <form class="login layui-form">
        <div class="login-top">
            登录
        </div>
        <div class="login-center clearfix">
            <!--隐藏的属性 ,默认值是 登录-->
            <input type="hidden" name="service" value="login" />
            <div class="login-center-img"><img src="../static/img/name.png"/></div>
            <div class="login-center-input">
                <input type="text" name="num" id="num" placeholder="用户名" lay-verify="required"  onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的用户名'"/>
                <div class="login-center-input-text">用户名</div>
            </div>
        </div>
        <div class="login-center clearfix">
            <div class="login-center-img"><img src="../static/img/password.png"/></div>
            <div class="login-center-input">
                <input type="password" name="pwd" id="pwd"  placeholder="用户密码" lay-verify="required" onfocus="this.placeholder=''" onblur="this.placeholder='请输入您的密码'"/>
                <div class="login-center-input-text">密码</div>
            </div>
        </div>
        <div class="login-center clearfix">
            <div class="login-center-img"><img src="../static/img/password.png"/></div>
            <div class="login-center-input">
                <input type="text" name="checkCode" id="code" placeholder="验证码" lay-verify="required"  style="width: 120px"/>
                <div class="login-center-input-text">验证码</div>
                <img id="checkCode" alt="验证码" src="/checkCode/code" style="width: 70px;margin-left: 20px">
            </div>
        </div>
        <div class="login-center clearfix">
            <div class="login-center-img"><img src="../static/img/password.png"/></div>
            <div class="login-center-input">
                <select  name="type" lay-filter="aihao">
                    <option value="0">管理员</option>
                    <option value="1" selected="">医生</option>
                </select>
            </div>
        </div>
        <div class="login-center clearfix">
            <div class="login-center-img"></div>
            <div class="login-center-input">
            <div class="layui-btn layui-btn-radius layui-btn-normal" lay-submit lay-filter="loginBtnFilter">
                登录
            </div>
            <div class="layui-btn layui-btn-radius layui-btn-normal" lay-submit id="loginInsert">
                注册
            </div>
            <div class="layui-btn layui-btn-radius layui-btn-normal" lay-submit id="loginReset">
                重置
                    </div>
                </div>
            </div>

    </form>
    <div class="sk-rotating-plane"></div>
</div>
<div style="text-align:center;">
</div>

<script src="../static/layui/layui.js"></script>
<!--登录页调整星空粒子间隔,坐标...-->
<script src="../static/js/particles.min.js"></script>
<script src="../static/js/app.js"></script>
<script>
    layui.use(['form','layer','jquery'], function(){
        var form = layui.form;
        var layer = layui.layer;
        var $ = layui.jquery;
        //监听提交
        form.on('submit(loginBtnFilter)', function(d){
            $.post('/login/UserLogin',d.field,function (rs) {
                console.log(rs);
                if(rs.type=='success'){
                    location.href='/login/index';
                    return false;
                }
                //登陆失败提示信息
                layer.msg(rs.msg);
                //刷新验证码
                $("#checkCode").click();
                $("input[name='checkCode']").val("");//清空之前输入框的数据
            });
            return false;//阻止表单默认提交
        });

        //验证码点击事件
        $("#checkCode").click(function () {
            $(this).attr("src","/checkCode/code?"+new Date());
        });

        $("#loginInsert").click(function () {
            layer.open({
                type: 2,
                title: '注册页面',
                shadeClose: true,
                shade: 0.4,
                area: ['500px', '40%'],
                content: '/view/admin/add.html' ,//iframe的url
            });


        });

        //点击弹出注册页面
        $("#loginInsert").click(function () {
            $(this).attr("src","/checkCode/code?"+new Date());
        });
        //重置
        $("#loginReset").click(function () {
            //1.刷新页面  location.reload();
            //2.通过jquer赋值，进行重置
        $("#num").val("");
        $("#pwd").val("");
        $("#code").val("");
        });

    });
</script>
</body>
</html>









